FROM python:3.11-slim-bullseye

WORKDIR /opt/fastapi-admin
ADD requirements.txt .

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core-apt \
    --mount=type=cache,target=/var/lib/apt,sharing=locked,id=core-apt \
    sed -i "s@http://.*.debian.org@http://mirrors.ustc.edu.cn@g" /etc/apt/sources.list \
    && rm -f /etc/apt/apt.conf.d/docker-clean \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && apt-get update \
    && apt-get install -y --no-install-recommends gcc python3-dev bash vim curl procps net-tools

RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

ENV LANG=zh_CN.UTF-8
EXPOSE 80
ENTRYPOINT [ "python", "run.py" ]